#include <iostream>
#include <algorithm>
#include <cstdio>
#include <array>
#include <map>
#include <vector>
#define pii pair <int, int>
using namespace std;
#ifdef ONLINE_JUDGE

//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[1 << 23], *p1 = buf, *p2 = buf, ubuf[1 << 23], *u = ubuf;

#endif
int read() {
	int p = 0, flg = 1;
	char c = getchar();
	while (c < '0' ||c > '9') {
		if (c == '-') flg = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		p = p * 10 + c - '0';
		c = getchar();
	}
	return p * flg;
}
void write(int x) {
	if (x < 0) {
		x = -x;
		putchar('-');
	}
	if (x > 9) {
		write(x / 10);
	}
	putchar(x % 10 + '0');
}
bool _stmer;

#define fi first
#define se second

const int N = 1e6 + 5, M = 5e5 + 5, inf = 2e9;

namespace Sgt1 {

array <vector <pii>, N * 4> edge;

void modify(int x, int l, int r, int L, int R, pii y) {
	if (L > r || R < l) return;
	if (L <= l && R >= r) { edge[x].push_back(y); return; }
	int mid = (l + r) >> 1;
	if (L <= mid) modify(x * 2, l, mid, L, R, y);
	if (R > mid) modify(x * 2 + 1, mid + 1, r, L, R, y);
}

} //namespace Sgt1

namespace Sgt2 {

array <pii, N * 4> edge;

pii update(pii x, pii y) { return make_pair(min(x.fi, y.fi), max(x.se, y.se)); }

void pushup(int x) { edge[x] = update(edge[x * 2], edge[x * 2 + 1]); }

void modify1(int x, int l, int r, int k, int y) {
	if (l == r) { edge[x].se = y; return; }
	int mid = (l + r) >> 1;
	if (k <= mid) modify1(x * 2, l, mid, k, y);
	else modify1(x * 2 + 1, mid + 1, r, k, y);
	pushup(x);
}

void modify2(int x, int l, int r, int k, int y) {
	if (l == r) { edge[x].fi = y; return; }
	int mid = (l + r) >> 1;
	if (k <= mid) modify2(x * 2, l, mid, k, y);
	else modify2(x * 2 + 1, mid + 1, r, k, y);
	pushup(x);
}

pii query(int x, int l, int r, int L, int R) {
	if (L > r || R < l) return make_pair(inf, -1);
	if (L <= l && R >= r) return edge[x];
	int mid = (l + r) >> 1; pii ans(inf, -1);
	if (L <= mid) ans = update(ans, query(x * 2, l, mid, L, R));
	if (R > mid) ans = update(ans, query(x * 2 + 1, mid + 1, r, L, R));
	return ans;
}

} //namespace Sgt2

char strbuf[2];

array <int, N> ans;

array <map <int, int>, N> req1, req2;

void delet(int x) {
	for (auto k : Sgt1::edge[x]) {
		req1[k.se][k.fi]--, req2[k.fi][k.se]--;
		if (!req1[k.se][k.fi]) req1[k.se].erase(k.fi);
		if (!req2[k.fi][k.se]) req1[k.fi].erase(k.se);
		if (!req1[k.se].empty())
			Sgt2::modify1(1, 1, 1e6, k.se, (--req1[k.se].end()) -> fi);
		else
			Sgt2::modify1(1, 1, 1e6, k.se, -1);
		if (!req2[k.fi].empty())
			Sgt2::modify2(1, 1, 1e6, k.fi, req2[k.fi].begin() -> fi);
		else
			Sgt2::modify2(1, 1, 1e6, k.fi, inf);
	}
}

void dfs(int x, int res, int l, int r) {
	for (auto k : Sgt1::edge[x]) {
		int tp1 = Sgt2::query(1, 1, 1e6, 1, k.fi - 1).se,
			tp2 = Sgt2::query(1, 1, 1e6, k.se + 1, 1e6).fi;
		if (~tp1) res = min(res, k.se - tp1 + 1);
		if (tp2 != inf) res = min(res, tp2 - k.fi + 1);
		req1[k.se][k.fi]++, req2[k.fi][k.se]++;
		Sgt2::modify1(1, 1, 1e6, k.se, (--req1[k.se].end()) -> fi);
		Sgt2::modify2(1, 1, 1e6, k.fi, req2[k.fi].begin() -> fi);
	}
	if (l == r) {
		if (!~ans[l]) ans[l] = res;
		delet(x);
		return;
	}
	int mid = (l + r) >> 1;
	dfs(x * 2, res, l, mid), dfs(x * 2 + 1, res, mid + 1, r);
	delet(x);
}

map <pii, vector <int> > mp;

bool _edmer;
int main() {
	cerr << (&_stmer - &_edmer) / 1024.0 / 1024.0 << "MB\n";
#ifndef cxqghzj
	freopen("stone.in", "r", stdin);
	freopen("stone.out", "w", stdout);
#endif
	int n = read(); map <int, int> isl1, isl2;
	for (int i = 1; i <= n; i++) {
		scanf("%s", strbuf);
		pii st; st.fi = read(), st.se = read() - 1;
		if (strbuf[0] == 'A') {
			mp[st].push_back(i);
			isl1[st.fi]++;
			isl2[st.se]++;
			req1[st.se][st.fi]++, req2[st.fi][st.se]++;
		}
		else {
			isl1[st.fi]--;
			isl2[st.se]--;
			if (!isl1[st.fi]) isl1.erase(st.fi);
			if (!isl2[st.se]) isl2.erase(st.se);
			Sgt1::modify(1, 1, n, mp[st].front(), i - 1, st);
			mp[st].pop_back();
			if (mp[st].empty()) mp.erase(st);
			req1[st.se][st.fi]--, req2[st.fi][st.se]--;
			if (!req1[st.se][st.fi]) req1[st.se].erase(st.fi);
			if (!req2[st.fi][st.se]) req1[st.fi].erase(st.se);
		}
		int r = isl2.begin() -> fi, l = (--isl1.end()) -> fi;
		if (r < l) ans[i] = -1;
		else {
			ans[i] = req2[l].begin() -> fi - (--req1[r].end()) -> fi + 1;
		}
	}
	for (auto k : mp)
		Sgt1::modify(1, 1, n, k.se.front(), n, k.fi);
	for (int i = 1; i <= 1e6; i++)
		req1[i].clear(), req2[i].clear();
	Sgt2::edge.fill(make_pair(inf, -1));
	dfs(1, 2e9, 1, n);
	for (int i = 1; i <= n; i++)
		write(ans[i]), puts("");
	return 0;
}
